/**
 * Created by Mark on 2018/4/17.
 * 地址模块业务请求
 */


var _mm = require("util/mm.js");

var _address = {
    //1.获取收货地址列表
    getAddressList : function(resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/list.do'),
            success : resolve,
            data :{
                pageSize : 50
            },
            error   : reject
        });
    },
    //2.添加收货地址
    save : function(addressInfo,resolve, reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/add.do'),
            success : resolve,
            data :addressInfo,
            method : "post",
            error   : reject
        });
    },
    //3.根据id删除收货地址
    deleteAddress : function (shippingId,resolve, reject) {
        _mm.request({
            url     : _mm.getServerUrl('/shipping/delete.do'),
            success : resolve,
            data : {
                shippingId : shippingId
            },
            error   : reject
        });
    },
    //4.根据id获取单个收货地址
    getAddress : function (shippingId,resolve, reject) {
        _mm.request({
            url     : _mm.getServerUrl('/shipping/select.do'),
            success : resolve,
            data : {
                shippingId : shippingId
            },
            error   : reject
        });
    },
    //5.更新收货地址
    updateAddress : function (addressInfo,resolve, reject) {
        _mm.request({
            url     : _mm.getServerUrl('/shipping/update.do'),
            success : resolve,
            method : "post",
            data : addressInfo,
            error   : reject
        });
    }
}

module.exports = _address;